﻿using System;

namespace diantou.web.enterprise
{
    /// <summary>
    /// 考试邀请
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPage = false, IsPool = true)]
    partial class reInvite : examPermissionView<reInvite>
    {
        /// <summary>
        /// 默认空模版
        /// </summary>
        private static readonly diantou.examDataAccess.enterpriseMail nullMail = new diantou.examDataAccess.enterpriseMail { IsEmail = true, Name = "请选择", Title = string.Empty, Content = string.Empty };
        /// <summary>
        /// 默认空模版
        /// </summary>
        private static readonly diantou.examDataAccess.enterpriseMail nullSms = new diantou.examDataAccess.enterpriseMail { IsEmail = false, Name = "请选择", Title = string.Empty, Content = string.Empty };
        /// <summary>
        /// 考试
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private diantou.examDataAccess.exam exam;
        /// <summary>
        /// 考试邀请
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private diantou.examDataAccess.examInvitation invitation;
        /// <summary>
        /// 邮件模版
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private diantou.examDataAccess.enterpriseMail mail;
        /// <summary>
        /// 邮件模板集合
        /// </summary>
        private diantou.examDataAccess.enterpriseMail[] mails
        {
            get { return mail.IsEmail ? examDataAccess.tcpCall.enterpriseMail.get(currentUserId, true) : examDataAccess.tcpCall.enterpriseMail.get(currentUserId, false); }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="invitationId"></param>
        /// <returns></returns>
        private bool loadView(int invitationId)
        {
            invitation = diantou.examDataAccess.tcpCall.examInvitation.get(invitationId, currentUserId);
            if (invitation != null)
            {
                exam = diantou.examDataAccess.clientCache.Exam[invitation.ExamId];
                if (exam != null)
                {
                    mail = invitation.Mobile == 0 ? nullMail : nullSms;
                    return true;
                }
            }
            AjaxResponse(webConfig.NotFound404);
            return false;
        }
    }
}
